module.exports = app => {
    return class Record extends app.Service {
        async page(page=1,row=15,query={},params={}) {
            if(isNaN(page))
            page = isNaN(page)?page*1:page;
            row = isNaN(row)?row*1:row;
            var _q = query;

            if(params.keyword){
                _q['$or'] = [
                    // {}
                ]
            }
            if(params.btime && params.etime){
                _q['createDate'] = {"$gte":`${params.btime} 00:00:00`,"$lte":`${params.etime} 23:59:59`}
            }else if(params.btime){
                _q['createDate'] = {"$gte":`${params.btime} 00:00:00 `}
            }else if(params.etime){
                _q['createDate'] = {"$lte":`${params.etime} 23:59:59 `}
            }
            if(params.placeId){
                _q['place.id'] = params.placeId;
            }
            console.log(_q);

            /* let _q = this.ctx.model.Record.find(_q).skip((page-1)*row).limit(row);
            let count = await _q.count();
            if(count === 0){
                return {
                    total:0,
                    data:[]
                };
            }
            return _q. */
            console.log(row);
            return await this.ctx.model.Record.find(_q).skip((page-1)*row).limit(row);
        }
    }
    }
    